/**
 * https://leetcode.cn/submissions/detail/560806871/
 * 300. 最长递增子序列
 * Medium 黄伟杰 2024.9.2
 * 线性DP
 */

#include <bits/stdc++.h>
using namespace std;

class Solution
{
public:
    int lengthOfLIS(vector<int> &nums)
    {
        int n = nums.size();
        int ans = 0;
        vector<int> dp(n, 1);
        for (int i = 1; i < n; i++)
        {
            int x = 1;
            for (int j = 0; j < i; j++)
            {
                if (nums[i] > nums[j])
                {
                    x = max(dp[j] + 1, x);
                }
            }
            dp[i] = x;
        }
        for (int i = 0; i < n; i++)
        {
            ans = max(ans, dp[i]);
            cout << dp[i] << endl;
        }

        return ans;
    }
};